<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateDailyChallengesTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('daily_challenges', function (Blueprint $table) {
            $table->bigIncrements('id');
            $table->string('challenge_key', 50)->unique();
            $table->string('title', 200);
            $table->text('description');
            $table->unsignedTinyInteger('difficulty_level')->default(1)->comment('难度等级 1-5');
            $table->unsignedInteger('reward_points')->default(10);
            $table->boolean('is_active')->default(true);
            $table->timestamp('created_at')->useCurrent();
            
            // 索引
            $table->index(['is_active']);
            $table->index(['difficulty_level']);
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('daily_challenges');
    }
}